﻿
# # 添加FetchContent模块
# include(FetchContent)
# # 下载并配置spdlog
# FetchContent_Declare(
#     spdlog
#     GIT_REPOSITORY https://github.com/gabime/spdlog.git
#     GIT_TAG        v1.14.1  # 使用稳定版本
# )
# FetchContent_MakeAvailable(spdlog)


# 添加子目录，首先构建spdlog库
add_subdirectory(vendor/spdlog)
# 添加子目录，首先构建glm库
add_subdirectory(vendor/glm)
# 添加子目录，首先构建glad库
add_subdirectory(vendor/glad)
# 添加子目录，首先构建GLFW库
add_subdirectory(vendor/GLFW)
# 创建一个静态库目标，名为 "Hazel"
add_library(Hazel STATIC)

# Hazel/CMakeLists.txt
find_package(OpenGL REQUIRED)
# 设置预编译头文件
target_precompile_headers(Hazel PRIVATE
    src/hzpch.h
)

# 设置目标的包含目录
target_include_directories(Hazel
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
        
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/src
        ${CMAKE_CURRENT_SOURCE_DIR}/vendor/spdlog/include  # 添加spdlog头文件路径
        ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glm/glm  # 添加glm头文件路径
        ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glad/include  # 添加glad头文件路径
        ${CMAKE_CURRENT_SOURCE_DIR}/vendor/GLFW/include  # 添加GLFW头文件路径
)

# 使用 glad
# target_sources(Hazel PRIVATE vendor/glad/src/glad.c)
target_include_directories(Hazel PRIVATE vendor/glad/include)
# 链接spdlog glm库
target_link_libraries(Hazel PUBLIC OpenGL::GL spdlog::spdlog glm::glm glad glfw)



# 明确添加源文件
target_sources(Hazel PRIVATE
    src/Hazel.cpp
    src/Log.cpp
    src/Hazel/Core/Layer.cpp
    src/Hazel/Core/LayerStack.cpp
    src/Hazel/Core/WindowsOpenGLContext.cpp
    src/Hazel/Core/WindowsWindow.cpp
    src/Inputs/WindowsInput.cpp
    src/Renderer/Renderer.cpp
    src/Renderer/OpenGL/OpenGLVertexArray.cpp
    src/Renderer/OpenGL/OpenGLRendererAPI.cpp)

# 对于静态库，移除HZ_BUILD_DLL定义
# target_compile_definitions(Hazel PRIVATE HZ_BUILD_DLL)  # 注释掉或删除这行

# 如果将来要构建动态库，可以这样设置：
# set_target_properties(Hazel PROPERTIES
#     CXX_VISIBILITY_PRESET hidden
#     VISIBILITY_INLINES_HIDDEN ON
# )
